﻿using System;
using System.Collections.Generic;
using UnityEngine;

// Token: 0x020002DB RID: 731
public abstract class ShapeInfoBase
{
	// Token: 0x06001295 RID: 4757 RVA: 0x00086940 File Offset: 0x00084B40
	public ShapeInfoBase()
	{
		this.InitEnd = false;
		this.dictCategory = new Dictionary<int, List<ShapeInfoBase.CategoryInfo>>();
		this.dictDstBoneInfo = new Dictionary<int, ShapeInfoBase.BoneInfo>();
		this.dictSrcBoneInfo = new Dictionary<int, ShapeInfoBase.BoneInfo>();
	}

	// Token: 0x170001B6 RID: 438
	// (get) Token: 0x06001296 RID: 4758 RVA: 0x0008697C File Offset: 0x00084B7C
	// (set) Token: 0x06001297 RID: 4759 RVA: 0x00086984 File Offset: 0x00084B84
	public bool InitEnd { get; protected set; }

	// Token: 0x06001298 RID: 4760
	public abstract void InitShapeInfo(string assetBundleAnmKey, string assetBundleCategory, string anmKeyInfoName, string cateInfoName, Transform trfObj);

	// Token: 0x06001299 RID: 4761
	public abstract void InitShapeInfo(TextAsset anmKeyTxt, TextAsset categoryTxt, Transform trfObj);

	// Token: 0x0600129A RID: 4762 RVA: 0x00086990 File Offset: 0x00084B90
	protected void InitShapeInfoBase(string assetBundleAnmKey, string assetBundleCategory, string anmKeyInfoName, string cateInfoName, Transform trfObj, Dictionary<string, int> dictEnumDst, Dictionary<string, int> dictEnumSrc)
	{
		this.anmKeyInfo.LoadInfo(assetBundleAnmKey, anmKeyInfoName);
		this.LoadCategoryInfoList(assetBundleCategory, cateInfoName, dictEnumSrc);
		this.GetDstBoneInfo(trfObj, dictEnumDst);
		this.GetSrcBoneInfo();
	}

	// Token: 0x0600129B RID: 4763 RVA: 0x000869BC File Offset: 0x00084BBC
	protected void InitShapeInfoBase(TextAsset anmKeyInfoTxt, TextAsset categoryTxt, Transform trfObj, Dictionary<string, int> dictEnumDst, Dictionary<string, int> dictEnumSrc)
	{
		this.anmKeyInfo.LoadInfo(anmKeyInfoTxt);
		this.LoadCategoryInfoList(categoryTxt, dictEnumSrc);
		this.GetDstBoneInfo(trfObj, dictEnumDst);
		this.GetSrcBoneInfo();
	}

	// Token: 0x0600129C RID: 4764 RVA: 0x000869E4 File Offset: 0x00084BE4
	public void ReleaseShapeInfo()
	{
		this.InitEnd = false;
		this.dictCategory.Clear();
		this.dictDstBoneInfo.Clear();
		this.dictSrcBoneInfo.Clear();
	}

	// Token: 0x0600129D RID: 4765 RVA: 0x00086A10 File Offset: 0x00084C10
	private bool LoadCategoryInfoList(string assetBundleName, string assetName, Dictionary<string, int> dictEnumSrc)
	{
		TextAsset ta = AssetBundleLoader.LoadAsset<TextAsset>(GlobalData.assetBundlePath, assetBundleName, assetName);
		return this.LoadCategoryInfoList(ta, dictEnumSrc);
	}

	// Token: 0x0600129E RID: 4766 RVA: 0x00086A34 File Offset: 0x00084C34
	private bool LoadCategoryInfoList(TextAsset ta, Dictionary<string, int> dictEnumSrc)
	{
		ListDataLoader listDataLoader = new ListDataLoader();
		listDataLoader.Load_Text(ta, -1, -1);
		this.dictCategory.Clear();
		for (int i = 0; i < listDataLoader.Y_Num; i++)
		{
			ShapeInfoBase.CategoryInfo categoryInfo = new ShapeInfoBase.CategoryInfo();
			categoryInfo.Initialize();
			int key = int.Parse(listDataLoader[i, 0]);
			categoryInfo.name = listDataLoader[i, 1];
			int id = 0;
			if (!dictEnumSrc.TryGetValue(categoryInfo.name, out id))
			{
				string message = "SrcBone【" + categoryInfo.name + "】のID找不到";
				GlobalData.Debug_LogWarning(message);
			}
			else
			{
				categoryInfo.id = id;
				categoryInfo.use[0][0] = ((!(listDataLoader[i, 2] == "0")) ? true : false);
				categoryInfo.use[0][1] = ((!(listDataLoader[i, 3] == "0")) ? true : false);
				categoryInfo.use[0][2] = ((!(listDataLoader[i, 4] == "0")) ? true : false);
				if (categoryInfo.use[0][0] || categoryInfo.use[0][1] || categoryInfo.use[0][2])
				{
					categoryInfo.getflag[0] = true;
				}
				categoryInfo.use[1][0] = ((!(listDataLoader[i, 5] == "0")) ? true : false);
				categoryInfo.use[1][1] = ((!(listDataLoader[i, 6] == "0")) ? true : false);
				categoryInfo.use[1][2] = ((!(listDataLoader[i, 7] == "0")) ? true : false);
				if (categoryInfo.use[1][0] || categoryInfo.use[1][1] || categoryInfo.use[1][2])
				{
					categoryInfo.getflag[1] = true;
				}
				categoryInfo.use[2][0] = ((!(listDataLoader[i, 8] == "0")) ? true : false);
				categoryInfo.use[2][1] = ((!(listDataLoader[i, 9] == "0")) ? true : false);
				categoryInfo.use[2][2] = ((!(listDataLoader[i, 10] == "0")) ? true : false);
				if (categoryInfo.use[2][0] || categoryInfo.use[2][1] || categoryInfo.use[2][2])
				{
					categoryInfo.getflag[2] = true;
				}
				List<ShapeInfoBase.CategoryInfo> list = null;
				if (!this.dictCategory.TryGetValue(key, out list))
				{
					list = new List<ShapeInfoBase.CategoryInfo>();
					this.dictCategory[key] = list;
				}
				list.Add(categoryInfo);
			}
		}
		return true;
	}

	// Token: 0x0600129F RID: 4767 RVA: 0x00086D20 File Offset: 0x00084F20
	private bool GetDstBoneInfo(Transform trfBone, Dictionary<string, int> dictEnumDst)
	{
		this.dictDstBoneInfo.Clear();
		foreach (KeyValuePair<string, int> keyValuePair in dictEnumDst)
		{
			Transform transform = Transform_Utility.FindTransform(trfBone, keyValuePair.Key);
			if (null != transform)
			{
				ShapeInfoBase.BoneInfo boneInfo = new ShapeInfoBase.BoneInfo();
				boneInfo.trfBone = transform;
				this.dictDstBoneInfo[keyValuePair.Value] = boneInfo;
			}
			else
			{
				GlobalData.Debug_LogWarning("找不到的骨头:" + keyValuePair.Key);
			}
		}
		return true;
	}

	// Token: 0x060012A0 RID: 4768 RVA: 0x00086DD4 File Offset: 0x00084FD4
	private void GetSrcBoneInfo()
	{
		this.dictSrcBoneInfo.Clear();
		foreach (KeyValuePair<int, List<ShapeInfoBase.CategoryInfo>> keyValuePair in this.dictCategory)
		{
			int count = keyValuePair.Value.Count;
			for (int i = 0; i < count; i++)
			{
				ShapeInfoBase.BoneInfo value = null;
				if (!this.dictSrcBoneInfo.TryGetValue(keyValuePair.Value[i].id, out value))
				{
					value = new ShapeInfoBase.BoneInfo();
					this.dictSrcBoneInfo[keyValuePair.Value[i].id] = value;
				}
			}
		}
	}

	// Token: 0x060012A1 RID: 4769 RVA: 0x00086EA0 File Offset: 0x000850A0
	public bool ChangeValue(int category, float value)
	{
		if (this.anmKeyInfo == null)
		{
			return false;
		}
		if (!this.dictCategory.ContainsKey(category))
		{
			return false;
		}
		int count = this.dictCategory[category].Count;
		string name = string.Empty;
		for (int i = 0; i < count; i++)
		{
			List<ShapeInfoBase.CategoryInfo> list = this.dictCategory[category];
			ShapeInfoBase.BoneInfo boneInfo = null;
			int id = list[i].id;
			name = list[i].name;
			if (this.dictSrcBoneInfo.TryGetValue(id, out boneInfo))
			{
				Vector3[] array = new Vector3[3];
				for (int j = 0; j < 3; j++)
				{
					array[j] = Vector3.zero;
				}
				bool[] array2 = new bool[3];
				for (int k = 0; k < 3; k++)
				{
					array2[k] = list[i].getflag[k];
				}
				this.anmKeyInfo.GetInfo(name, value, ref array, array2);
				if (list[i].use[0][0])
				{
					boneInfo.vctPos.x = array[0].x;
				}
				if (list[i].use[0][1])
				{
					boneInfo.vctPos.y = array[0].y;
				}
				if (list[i].use[0][2])
				{
					boneInfo.vctPos.z = array[0].z;
				}
				if (list[i].use[1][0])
				{
					boneInfo.vctRot.x = array[1].x;
				}
				if (list[i].use[1][1])
				{
					boneInfo.vctRot.y = array[1].y;
				}
				if (list[i].use[1][2])
				{
					boneInfo.vctRot.z = array[1].z;
				}
				if (list[i].use[2][0])
				{
					boneInfo.vctScl.x = array[2].x;
				}
				if (list[i].use[2][1])
				{
					boneInfo.vctScl.y = array[2].y;
				}
				if (list[i].use[2][2])
				{
					boneInfo.vctScl.z = array[2].z;
				}
			}
		}
		return true;
	}

	// Token: 0x060012A2 RID: 4770
	public abstract void Update();

	// Token: 0x0400178E RID: 6030
	private Dictionary<int, List<ShapeInfoBase.CategoryInfo>> dictCategory;

	// Token: 0x0400178F RID: 6031
	protected Dictionary<int, ShapeInfoBase.BoneInfo> dictDstBoneInfo;

	// Token: 0x04001790 RID: 6032
	protected Dictionary<int, ShapeInfoBase.BoneInfo> dictSrcBoneInfo;

	// Token: 0x04001791 RID: 6033
	private AnimationKeyInfo anmKeyInfo = new AnimationKeyInfo();

	// Token: 0x020002DC RID: 732
	public class CategoryInfo
	{
		// Token: 0x060012A4 RID: 4772 RVA: 0x00087184 File Offset: 0x00085384
		public void Initialize()
		{
			for (int i = 0; i < 3; i++)
			{
				this.use[i] = new bool[3];
				this.getflag[i] = false;
			}
		}

		// Token: 0x04001792 RID: 6034
		public int id;

		// Token: 0x04001793 RID: 6035
		public string name = string.Empty;

		// Token: 0x04001794 RID: 6036
		public bool[][] use = new bool[3][];

		// Token: 0x04001795 RID: 6037
		public bool[] getflag = new bool[3];
	}

	// Token: 0x020002DD RID: 733
	public class BoneInfo
	{
		// Token: 0x04001796 RID: 6038
		public Transform trfBone;

		// Token: 0x04001797 RID: 6039
		public Vector3 vctPos = Vector3.zero;

		// Token: 0x04001798 RID: 6040
		public Vector3 vctRot = Vector3.zero;

		// Token: 0x04001799 RID: 6041
		public Vector3 vctScl = Vector3.one;
	}
}
